package com.share.iostream;

import java.util.*;
import java.io.*;

/**
 * 
 * @author Johnny Tam PrintWriter 针对字符
 */
public class TestPrintStream2 {
	public static void main(String[] args) {
		String s = null;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			FileWriter fw = new FileWriter(
					"E:\\Coursera-Java\\Eclipse\\workspace\\chapter18-IO\\src\\com\\share\\iostream\\logfile.log",
					true);
			PrintWriter log = new PrintWriter(fw);

			System.out.println("开始读取log文件信息！！！");

			System.out.println(br.readLine());
			
			while ((s = br.readLine()) != null) {
				System.out.println(s);
				if (s.equalsIgnoreCase("exit")) {
					break;
				}
				
				System.out.println(s.toUpperCase());
				
				log.println("-----");
				log.println(s.toUpperCase());
				log.flush();
			}
			
			log.println("===" + new Date() + "===");
			log.flush();
			log.close();
			System.out.println("end");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}